-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dconf: Check for changes properly despite style of quotes used by user #6049
dconf: Check for changes properly despite style of quotes used by user #6049
Conversation
I am not sure whom to ask to review this. Only @felixfontein and @bcoca have changelog entries in dconf.py, and their changes don't look functional? |
This comment was marked as outdated.
This comment was marked as outdated.
Hmm. My goal here was to make a minimal change to improve the behavior without risking breaking anything else. However, when I made that calculation I forgot that this would handle a single string but not an array or tuple of strings. That somewhat changes the calculus, and I am wondering if we want to make this a larger change which solves the problem "correctly.". The way to do that would be to use
The risk here is that this introduces a new dependency on the Perhaps the compromise answer would be to write the code so that
What do you tihink? And yeah, I should probably write some unit tests. :-/ (It's a good thing I am between jobs right now because otherwise I would not have time to fix this properly. ;-) ) |
d666fd2
to
3e189bd
Compare
OK, I've implemented the proposal above, let me know what you think. The one concern I have, and I'm not sure this is something I need to worry about or what to do about it if I do, is that the unit tests require the |
Well apparently I do need to worry about that given that a bunch of the checks are failing. I'm not sure how to proceed here. Any suggestions you have would be appreciated. Thanks! |
Docs Build 📝Thank you for contribution!✨ This PR has been merged and your docs changes will be incorporated when they are next published. |
Rather than removing the unit test, I would prefer to leave it in after adjusting the code so that the tests past even when |
This comment was marked as outdated.
This comment was marked as outdated.
@felixfontein thanks for your most excellent code review. I think I've responded to everything. Please take a look and let me know what you think. I will squash once you're OK with the changes so we don't send a bunch of cluttery commits to main. |
OK apparently I have to include something in the |
Direct string comparisons are an inaccurate way to compare two GVariant representations. For example, 'foo' and "foo" (including the quote marks, which are part of the representation) are equal GVariants but if you just do a string compare (remember, including the quotes) they'll be interpreted. We therefore want to use the `gi.repository` Python library to parse GVariant representations before comparing them whenever possible. However, we don't want to assume that this library will always be available or require it for Ansible to function, so we use a straight string comparison as a fallback when the library isn't available. This may result in some false positives, i.e., Ansible thinking a value is changing when it actually isn't, but will not result in incorrect values being written into `dconf`.
ec05fab
to
a79c7de
Compare
Looks good to me! I think there should be two follow-up PRs:
Are you interested in working on this? |
@felixfontein sure why not. Let's get this PR merged and backported and then I will start working on the other issues. |
Backport to stable-6: 💚 backport PR created✅ Backport PR branch: Backported as #6145 🤖 @patchback |
#6049) dconf: parse GVariant values to check for equality whenever possible Direct string comparisons are an inaccurate way to compare two GVariant representations. For example, 'foo' and "foo" (including the quote marks, which are part of the representation) are equal GVariants but if you just do a string compare (remember, including the quotes) they'll be interpreted. We therefore want to use the `gi.repository` Python library to parse GVariant representations before comparing them whenever possible. However, we don't want to assume that this library will always be available or require it for Ansible to function, so we use a straight string comparison as a fallback when the library isn't available. This may result in some false positives, i.e., Ansible thinking a value is changing when it actually isn't, but will not result in incorrect values being written into `dconf`. Co-authored-by: Jonathan Kamens <jik@jik5.kamens.us> (cherry picked from commit 627371e)
@jikamens thanks a lot for working on this! :) |
…rly despite style of quotes used by user (#6145) dconf: Check for changes properly despite style of quotes used by user (#6049) dconf: parse GVariant values to check for equality whenever possible Direct string comparisons are an inaccurate way to compare two GVariant representations. For example, 'foo' and "foo" (including the quote marks, which are part of the representation) are equal GVariants but if you just do a string compare (remember, including the quotes) they'll be interpreted. We therefore want to use the `gi.repository` Python library to parse GVariant representations before comparing them whenever possible. However, we don't want to assume that this library will always be available or require it for Ansible to function, so we use a straight string comparison as a fallback when the library isn't available. This may result in some false positives, i.e., Ansible thinking a value is changing when it actually isn't, but will not result in incorrect values being written into `dconf`. Co-authored-by: Jonathan Kamens <jik@jik5.kamens.us> (cherry picked from commit 627371e) Co-authored-by: Jonathan Kamens <jik@kamens.us>
Version 6.5.0 introduces a bug where keys must already exist when using dconf. See: - https://github.com/ansible-collections/community.general/blob/stable-6/CHANGELOG.rst - ansible-collections/community.general#6049 - ansible-collections/community.general#6271
Version 6.5.0 introduces a bug where keys must already exist when using dconf. See: - https://github.com/ansible-collections/community.general/blob/stable-6/CHANGELOG.rst - ansible-collections/community.general#6049 - ansible-collections/community.general#6271
SUMMARY
GVariant strings can use either single or double quotes, and therefore the user can use either single or double quotes when specifying a string value in their task, and what they choose to use may not match what is output by the dconf command, so for accurate comparison we need to strip the quotes and just compare what's inside them.
ISSUE TYPE
COMPONENT NAME
dconf